package com.mycharx.springboothibernate.common.key;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 雪花算法key生成配置
 *
 * @author 张卜亢
 * @date 2020.03.29 01:08:33
 */
@Configuration
public class SnowFlakeKeyGenConfig {
    @Value("${server.datacenterId:1}")
    private Long datacenterId;

    @Value("${server.machineId:1}")
    private Long machineId;

    @Bean
    public SnowFlake snowFlake() {
        return new SnowFlake(datacenterId, machineId);
    }

}
